package com.sanyue.solveLeetCode;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author sanyue
 * @version 1.0
 * @description: TODO
 * @date 2022/1/28 下午12:16
 */
public class solve {
    @Test
    public void solveIsStraight(){
        int[] nums = {0,0,8,5,4};
        boolean ans = isStraight(nums);
        System.out.println("ans:"+ans);
    }

    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int max = 0,min = 13;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0)continue;
            if (i>0&&nums[i] == nums[i-1])return false;
            max = max > nums[i] ? max : nums[i];
            min = min < nums[i] ? min : nums[i];
        }
        return max - min < 5;
    }
}
